{% extends "base.html" %}


{% block head %}

<link href="{{ static_url("assets/css/register.css") }}" rel="stylesheet">
<link href="{{ static_url("assets/css/main.css") }}" rel="stylesheet">
<link href="{{ static_url("assets/css/font-style.css") }}"  rel="stylesheet">
<link href="{{ static_url("assets/css/flexslider.css") }}" rel="stylesheet">


<style type="text/css">
      body {
        padding-top: 60px;
      }
</style>

<script type="text/javascript">
				function avatar_check() {
					{% if not current_user %}
			 			alert("请登陆！");
			 			document.location = "{{ request.protocol + "://" + request.host }}" + "/auth/login";
					{% end %}
				}
				function validate_imgupload(target) {
 					var uploadedFile = document.getElementById('avatar');
    				var fileSize = uploadedFile.files[0].size;
    				var size = fileSize / 1024;
    				if (size > 2000) {
    	 				alert("图书不能大于2M");
    					target.value = "";
    	 				return ;
    				}
    				var file_type = new Array("jpg","png","gif", "jpeg");
    				var file_name = target.value.split('.').pop();

    				if (file_type[0] != file_name && file_type[1] != file_name && file_type[2] != file_name && file_type[3] != file_name) {
    					alert("图片仅支持jpg、png、gif，jpeg格式");
    		 			target.value = "";
    		  			return;
    				}
				}
</script>
{% end %}


{% block body %}


 <div class="container">
        <div class="row">
        	<div class="col-lg-6">

        		<div class="register-info-wraper">
        			<div id="register-info">
        				<div class="cont">
        					<div class="thumbnail">
							<img src="{{ static_url(user["photo"]) }}" alt="Marcel Newman" class="img-circle">

             				<a href="#myModal1" class="btn" data-toggle="modal" onclick="avatar_check();">
				 				修改头像
			 				</a>

							</div><!-- /thumbnail -->
								<h2> {{ user["username"] }} </h2>
                            <br>
        				</div>
        				<div class="row">

        					<div class="col-lg-username" >
        						<div class="cont3">
        						<p><ok>累计推送:</ok> {{ user["push_count"] }}</p>

                                    <p><ok>累计上传:</ok> {{ user["upload_count"] }} </p>
        						<p><ok>验证邮箱:</ok> {{ user["email"] }} </p>
        						<p><ok>Kindle邮箱:</ok> {{ user["kindle_email"] }} </p>
        						</div>
        					</div>
        				</div><!-- /inner row -->
                        <br>
                        <br>
						<hr>
						<div class="cont2">
							<h2> Your Info </h2>
						</div>
						<br>


        			</div>
        		</div>

			<!-- Modal -->
			  <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
				   aria-hidden="true">
			    <div class="modal-dialog">
			      <div class="modal-content">
			        <div class="modal-header">
			          <!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>-->
			          <h4 class="modal-title"> 修改头像 </h4>
			        </div>

			        <div class="modal-footer">
                        <form enctype="multipart/form-data" method="post" action="/photo/{{ user["photo"] }}">
                            {% module xsrf_form_html() %}
                            <input type="file" name = "avatar_file" id="avatar" onchange="validate_imgupload(this);"/>
							<input type="hidden" name = "uri" value="{{ request.uri }}">
						   <button class="btn btn-default" type="submit"> 上传 </button>

						</form>
			       　</div>

			      </div><!-- /.modal-content -->
			    </div><!-- /.modal-dialog -->
			  </div><!-- /.modal -->

			</div>

		{% if current_user %}
        	<div class="col-sm-6 col-lg-6">
        		<div id="register-wraper">
        		    <form id="register-form" class="form" method="post" action="/username/{{ current_user }}">
        		        <legend>账户修改</legend>

        		        <div class="body">

        		        	<!--<label>用户ID</label>-->
        		        	<!--<input class="input-huge" type="text" name = "username">-->
        		        	<!-- email -->
        		        	<label>验证邮箱</label>
        		        	<input class="input-huge" type="text" name = "email">
                            <label>推送邮箱</label>
        		        	<input class="input-huge" type="text" name = "kindle_email">
        		        	<!-- password -->
        		        	<label>密码</label>
        		        	<input class="input-huge" type="password" name = "password">
                             {% module xsrf_form_html() %}
        		        </div>
						<br>
        		        <div class="footer">
        		            <!--<label class="checkbox inline">-->
        		                <!--<input type="checkbox" id="inlineCheckbox1" value="option1"> I agree with the terms &amp; conditions-->
        		            <!--</label>-->
        		            <button type="submit" class="btn btn-success" onclick="btn_click()">修改</button>
							<script type="text/javascript">
							function btn_click() {
								alert("修改成功！");
							}
						</script>
        		        </div>
        		    </form>
        		</div>
        	</div>
		{% end %}

        </div>

    </div>

{% end %}


{% block footer %}

<div id="footerwrap">
      	<footer class="clearfix"></footer>
      	<div class="container">
      		<div class="row">
      			<div class="col-sm-12 col-lg-12">
      			<p><img src="{{ static_url("assets/img/logo.png") }}" alt=""></p>
      			<p>For you a thousand - Copyright 2016</p>
      			</div>

      		</div><!-- /row -->
      	</div><!-- /container -->
	</div><!-- /footerwrap -->

{% end %}

